package com.daviteq.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.daviteq.dto.RoleUser;
import com.google.gson.Gson;

/**
 * Servlet implementation class GroupController
 */

public class GroupController extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public GroupController() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		PrintWriter printer=response.getWriter();
		Gson gs=new Gson();
		boolean result=false;
		String action=request.getParameter("action");
		if("getRole".equals(action)){
			List<RoleUser> groupUser = new ArrayList<RoleUser>();
			for(int i=1;i<=27;i++){
				RoleUser group=new RoleUser();
				group.setGroup("Group "+i);
				groupUser.add(group);
			}
			System.out.println("{groupUser:"+gs.toJson(groupUser)+"}");
			printer.println(gs.toJson(groupUser));
		}
	}

}
